package xzr2;


    public class TestClass {
        String name = "zhangsan";
        String passWord = "123456";
        public void login(String name,String passWord){
            if(!this.name.equals(name)){
                System.out.println("用户名错误！");
                throw new UserNameException("用户名错了！");
            }
            if(!this.passWord.equals(passWord)){
                System.out.println("密码错误！");
                throw new PasswordException("密码错了！");
            }
        }

        public static void main(String[] args) {
            TestClass testClass = new TestClass();
            try {
                testClass.login("zhangsan","12346");
            }catch (UserNameException e1){
                e1.printStackTrace();
                System.out.println("用户名异常~");
            }catch (PasswordException e2){
                e2.printStackTrace();
                System.out.println("密码异常！~");
            }finally {
                System.out.println("释放资源！！！");
            }


        }

    }

